
var sqlite3 = require('sqlite3');
var path = require("path");

sqlite3.verbose();
var _db = undefined;

//始终连接数据库
function db(){
    if(_db === undefined){
        _db = new sqlite3.Database(path.join(__dirname, "../db/sqlite3.db3"), sqlite3.OPEN_READWRITE,
            function (err) {
                if (err) {
                    util.log('FAIL on openning database ' + err);
                }
            });
    }
    return _db;
}

exports.db = db;